home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / html / util / genskunk next >
Text File  |  1998-07-27  |  10KB  |  408 lines

  1. #! /usr/local/bin/perl -w 
  2.  
  3. $0 =~ s,.*/,,;
  4. $version="v1.1";
  5. $program=$0;
  6. $debug=0;
  7. $mailto='mailto:skunkware@sco.com';
  8. $baseref='http://www.sco.com/skunkware';
  9. $homeref='http://www.sco.com/skunkware';
  10. $isweb=0;
  11.  
  12. sub usage {
  13.   warn "@_\n" if @_;
  14.   $! = 0;
  15.   die <<EOF;
  16. Usage: $0 -w | -c file name prev next
  17.   -w        - Generate pages for the Web
  18.   -c        - Generate pages for the CD-ROM
  19.   file      - name of the template (.tmpl) file
  20.   name      - the name of the package
  21.   prev      - the name of the previous link
  22.   next      - the name of the next link
  23.   base      - the base href prefix to use
  24.  
  25.   Use the word NONE for the prev and next parameters if the page doesnt
  26.   have a previous or next page in the document chain.
  27.  
  28. EOF
  29. }
  30.  
  31. if (@ARGV<1 || $#ARGV != 5) {
  32.   usage();
  33. }
  34.  
  35. $mode="0";
  36.  
  37. if($ARGV[0] eq "-w" || $ARGV[0] eq "web") {
  38.   $mode="SKUNK_WEB";
  39.   $isweb=1;
  40. }
  41. elsif($ARGV[0] eq "-c" || $ARGV[0] eq "cd") {
  42.   $mode="SKUNK_CD";
  43. }
  44.  
  45. if ($mode eq "0") {
  46.   usage();
  47. }
  48.  
  49. $now=`date '+%A %b %d, %Y at %T %Z'`; chop $now;
  50. $basefile=$ARGV[1];
  51. $shortname=$ARGV[2];
  52. $previous=$ARGV[3];
  53. $next=$ARGV[4];
  54. $baseref=$ARGV[5];
  55. $realbase=`basename $basefile`; chop $realbase;
  56. #if ($isweb) {
  57. #  if (not -d $shortname) {
  58. #    mkdir($shortname,0755) or die "$program error: Could not create directory $shortname\n";
  59. #  }
  60. #  $output="$shortname/index.html";
  61. #} else {
  62.   $output="${realbase}.html";
  63. #}
  64. $template="${basefile}.tmpl";
  65. $templflt="/lib/cpp -I. -I.. -I../src -D$mode $template |";
  66.  
  67. -f $template or die "$program error: $template not found\n";
  68.  
  69. if ($debug) {
  70.  print "basefile : $basefile\n";
  71.  print "now      : $now\n";
  72.  print "shortname: $shortname\n";
  73.  print "previous : $previous\n";
  74.  print "next     : $next\n";
  75.  print "output   : $output\n";
  76.  print "realbase : $realbase\n";
  77.  print "template : $template\n";
  78. }
  79.  
  80. if ($previous eq "none" or $previous eq "NONE")
  81. {
  82.     $prevref="";
  83. } else {
  84.     $prevref="<AREA SHAPE=\"rect\" COORDS=\"112,2,236,26\" HREF=\"$baseref/$previous.html\">";
  85. }
  86.  
  87. if ($next eq "none" or $next eq "NONE") {
  88.     $nextref="";
  89. } else {
  90.     $nextref="<AREA SHAPE=\"rect\" COORDS=\"252,1,331,26\" HREF=\"$baseref/$next.html\">";
  91. }
  92.  
  93. if ($debug) {
  94.  print "nextref=$nextref\n";
  95.  print "prevref=$prevref\n";
  96. }
  97.  
  98. open (TEMPLATE,$templflt) or die "$program error: cannot open $template for reading\n";
  99. open (OUTPUT,">$output") or die "$program error: cannot open $output for output\n";
  100.  
  101. sub skunkheader{
  102.     my($foo) = @_;
  103.     my($title,$plink,$nlink) = split(/;/,$foo);
  104.     my($oplink,$onlink);
  105.     if (not $plink) {
  106.         $oplink = $prevref;
  107.     } else {
  108.         $oplink="<AREA SHAPE=\"rect\" COORDS=\"112,2,236,26\" HREF=\"$plink.html\">";
  109.     }
  110.     if (not $nlink) {
  111.         $onlink = $nextref;
  112.     } else {
  113.         $onlink="<AREA SHAPE=\"rect\" COORDS=\"252,1,331,26\" HREF=\"$nlink.html\">";
  114.     }
  115.  
  116.     if ($debug) {
  117.         print "skunkheader: title='$title'\n";
  118.         print "             oplink='$oplink'\n";
  119.         print "             onlink='$onlink'\n";
  120.     }
  121.  
  122.     if (not $title) {
  123.         warn "$program: No TITLE specified in SKUNKHEADER\n";
  124.     }
  125.  
  126.     if (not $isweb) {
  127. #
  128. # This is the header information for the Skunkware CD-ROM
  129. #
  130.         print OUTPUT <<EOF;
  131. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  132. <!-- DO NOT EDIT -->
  133. <!-- Automatically generated from $template by $program $version -->
  134. <!-- DO NOT EDIT -->
  135. <HTML>
  136. <HEAD>
  137.   <TITLE>$title</TITLE>
  138.   <LINK REV="made" HREF="$mailto">
  139. </HEAD>
  140. <BODY BGCOLOR="#ffffff">
  141.  
  142. <MAP NAME="skunknav">
  143.   <AREA SHAPE="rect" COORDS="347,1,460,26" HREF="$homeref/$shortname">
  144.   $oplink
  145.   $onlink
  146.   <AREA SHAPE="rect" COORDS="3,1,93,26" HREF="$baseref/index.html">
  147. </MAP>
  148.  
  149. <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%" BORDER="0">
  150.   <TR ALIGN="LEFT" VALIGN="TOP">
  151.     <TD ROWSPAN="2" WIDTH="20%">
  152. <A HREF="http://www.sco.com/skunkware">
  153.       <IMG BORDER=0 SRC="gif/skunkware.gif" HEIGHT="80" WIDTH="108" ALIGN="BOTTOM">
  154. </A>
  155.     </TD>
  156.     <TD VALIGN="BOTTOM" WIDTH="79%">
  157.       <IMG ISMAP USEMAP="#skunknav" SRC="gif/skunknav.gif" HEIGHT="26"
  158.           WIDTH="466" ALIGN="BOTTOM" BORDER="0">
  159.     </TD>
  160.   </TR>
  161.   <TR>
  162.     <TD VALIGN="TOP">
  163.       <IMG SRC="gif/${shortname}.gif" ALT="$title" ALIGN="BOTTOM">
  164.     </TD>
  165.   </TR>
  166. </TABLE>
  167.  
  168. EOF
  169.   } else {
  170. #
  171. # This is the header information for the Skunkware On-line pages
  172. #
  173.     print OUTPUT <<EOF;
  174. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  175. <!-- DO NOT EDIT -->
  176. <!-- Automatically generated from $template by $program $version -->
  177. <!-- DO NOT EDIT -->
  178. <HTML>
  179. <HEAD>
  180.   <TITLE>$title</TITLE>
  181.   <LINK REV="made" HREF="$mailto">
  182. </HEAD>
  183. <BODY BGCOLOR="#ffffff">
  184.  
  185. <MAP NAME="skunknav">
  186.   <AREA SHAPE="rect" COORDS="0,0,132,25" HREF="http://www.sco.com/products">
  187.   <AREA SHAPE="rect" COORDS="133,0,214,25" HREF="http://www.sco.com/skunkware/">
  188.   <AREA SHAPE="rect" COORDS="215,0,350,25" HREF="http://www.sco.com/feedback/">
  189.   <AREA SHAPE="rect" COORDS="351,0,465,25" HREF="http://search.sco.com/">
  190. </MAP>
  191.  
  192. <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%" BORDER="0">
  193.   <TR ALIGN="LEFT" VALIGN="TOP">
  194.     <TD ROWSPAN="2" WIDTH="20%">
  195. <A HREF="http://www.sco.com/skunkware">
  196.       <IMG BORDER=0 SRC="gif/skunkware.gif" HEIGHT="80" WIDTH="108" ALIGN="BOTTOM">
  197. </A>
  198.     </TD>
  199.     <TD VALIGN="TOP" WIDTH="79%">
  200.       <IMG ISMAP USEMAP="#skunknav" SRC="gif/navbar-head.gif" HEIGHT="26"
  201.           WIDTH="466" ALIGN="BOTTOM" BORDER="0">
  202.     </TD>
  203.   </TR>
  204.   <TR>
  205.     <TD VALIGN="TOP">
  206.       <IMG SRC="gif/${shortname}.gif" ALT="$title" ALIGN="BOTTOM">
  207.     </TD>
  208.   </TR>
  209. </TABLE>
  210.  
  211. EOF
  212.   }
  213. }
  214.  
  215. sub skunkfooter {
  216.     my($foo) = @_;
  217.  
  218.     if ($isweb) {
  219. #
  220. # Print out the footer of a page for the On-line version of the page.
  221. # This should conform to the corporate guidelines.
  222. #
  223.         print OUTPUT <<EOF;
  224. <P><HR ALIGN=LEFT>
  225. <P ALIGN="CENTER">Last Updated: $now</P>
  226. <P><HR ALIGN=LEFT>
  227. <P> <FONT SIZE=-2>
  228. © Copyright 1997 The Santa Cruz Operation, Inc. All rights reserved.
  229. </FONT>
  230. </BODY>
  231. </HTML>
  232. EOF
  233.     } else {
  234. #
  235. # Print out the fotter for the CD-ROM version.
  236. #
  237.         print OUTPUT <<EOF;
  238. <P><HR ALIGN=LEFT>
  239. <P ALIGN="CENTER">Last Updated: $now</P>
  240. <P><HR ALIGN=LEFT>
  241. <P> <FONT SIZE=-2>
  242. © Copyright 1997 The Santa Cruz Operation, Inc. All rights reserved.
  243. </FONT>
  244. </BODY>
  245. </HTML>
  246. EOF
  247.     }
  248. }
  249.  
  250. sub start_packagelist {
  251.     my($foo) = @_;
  252.  
  253.     print OUTPUT <<EOF;
  254. <H2 ALIGN="CENTER">Package List</H2>
  255. <CENTER><TABLE WIDTH="100%" BORDER="1" CELLSPACING="0" CELLPADDING="2">
  256.   <TR>
  257.     <TH WIDTH="11%" HEIGHT="23">Name</TH>
  258.     <TH WIDTH="62%">Description</TH>
  259.     <TH WIDTH="9%">Version</TH>
  260.     <TH WIDTH="7%">OSR5</TH>
  261.     <TH WIDTH="11%">UnixWare</TH>
  262.   </TR>
  263. EOF
  264. }
  265.  
  266. sub end_packagelist {
  267.     my($foo) = @_;
  268.  
  269.     print OUTPUT <<EOF;
  270. </TABLE></CENTER>
  271. <H4><HR ALIGN="LEFT"></H4>
  272. EOF
  273. }
  274.  
  275. sub startpack {
  276.     my($linkref,$desc) = @_;
  277.     print OUTPUT <<EOF;
  278. <H4><A NAME="$linkref"></A>$desc (package name <I>$linkref</I>)</H4>
  279. <BLOCKQUOTE>
  280. EOF
  281. }
  282.  
  283. sub endpack {
  284.     my($foo) = @_;
  285.  
  286.     print OUTPUT <<EOF;
  287. </BLOCKQUOTE>
  288. <P> </P>
  289. EOF
  290. }
  291.  
  292. sub source {
  293.     my($site) = @_;
  294.  
  295.     print OUTPUT <<EOF;
  296. <P>
  297. <A HREF="$site">
  298.   <IMG SRC="gif/origsrc.gif" ALT="Original source code" HSPACE="20" BORDER="0"
  299.             HEIGHT="32" WIDTH="160" ALIGN="CENTER"></A>
  300. <A HREF="$site">$site</A></P>
  301. EOF
  302. }
  303.  
  304. sub homepage {
  305.     my($page) = @_;
  306.  
  307.     print OUTPUT <<EOF;
  308. <P>
  309. <A HREF="$page">
  310.   <IMG SRC="gif/homepage.gif" ALT="Package Home page" HSPACE="20" BORDER="0"
  311.             HEIGHT="32" WIDTH="160" ALIGN="CENTER"></A>
  312. <A HREF="$page">$page</A></P>
  313. EOF
  314. }
  315.  
  316. sub osr5dist {
  317.     my($location) = @_;
  318.     my($volfile);
  319.     if ($location =~ /http\:\/\// || $location =~ /ftp\:\/\//) {
  320.         print OUTPUT <<EOF;
  321. <P><A HREF="$location">
  322.   <IMG SRC="gif/osr5dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  323.   ALIGN="CENTER" ALT="OpenServer Distribution">
  324. $location
  325. </A></P>
  326. EOF
  327.     } else {
  328.     if ($location =~ /osr5\//) {
  329.         if ($location =~ /\.gz$/) {
  330.             $volfile = "$location";
  331.         } else {
  332.           if (not $location =~ /\/$/) {
  333.             $volfile="${location}/VOLS.tar";
  334.           } else {
  335.             $volfile="${location}VOLS.tar";
  336.           }
  337.         }
  338.         print OUTPUT <<EOF;
  339. <P><A HREF="$baseref/$volfile">
  340.   <IMG SRC="gif/osr5dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  341.   ALIGN="CENTER" ALT="OpenServer Distribution"></A>
  342. <A HREF="$baseref/$location">$location</A></P>
  343. EOF
  344.     } else {
  345.         print OUTPUT <<EOF;
  346. <P><A HREF="$location">
  347.   <IMG SRC="gif/osr5dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  348.   ALIGN="CENTER" ALT="OpenServer Distribution">
  349. $location
  350. </A></P>
  351. EOF
  352.     }
  353.     }
  354. }
  355.  
  356. sub uw2dist {
  357.     my($location) = @_;
  358.     my($volfile);
  359.     if ($location =~ /http\:\/\// || $location =~ /ftp\:\/\//) {
  360.         print OUTPUT <<EOF;
  361. <P><A HREF="$location">
  362.   <IMG SRC="gif/uw2dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  363.   ALIGN="CENTER" ALT="UnixWare Distribution">
  364. $location
  365. </A></P>
  366. EOF
  367.     } else {
  368.         print OUTPUT <<EOF;
  369. <P><A HREF="$baseref/$location">
  370.   <IMG SRC="gif/uw2dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  371.   ALIGN="CENTER" ALT="UnixWare Distribution"></A>
  372. <A HREF="$baseref/$location">$location</A></P>
  373. EOF
  374.     }
  375. }
  376.  
  377. sub packlist{
  378.     my($foo) = @_;
  379.     my($linkref,$desc,$packver,$isosr5,$isuw2) = split(/;/, $foo);
  380.  
  381.     print OUTPUT <<EOF;
  382. <TR>
  383.   <TD><A HREF="#$linkref">$linkref</A></TD>
  384.   <TD>$desc</TD>
  385.   <TD>$packver</TD>
  386.   <TD ALIGN="CENTER">$isosr5</TD>
  387.   <TD ALIGN="CENTER">$isuw2</TD>
  388. </TR>
  389. EOF
  390. }
  391.  
  392. LINE: while (defined($line = <TEMPLATE>)) {
  393.     next LINE if $line =~ /^# [0-9]* \"/;
  394.     chop $line;
  395.     if ($line =~ s/@@\@SKUNKHEADER\((.*)\)//) { skunkheader($1);}
  396.     elsif ($line =~ s/@@\@SKUNKFOOTER//) { skunkfooter();}
  397.     elsif ($line =~ s/@@\@START_PACKAGELIST//) {start_packagelist();}
  398.     elsif ($line =~ s/@@\@END_PACKAGELIST//) {end_packagelist();}
  399.     elsif ($line =~ s/@@\@STARTPACK\((.*);(.*)\)//) {startpack($1,$2);}
  400.     elsif ($line =~ s/@@\@ENDPACK//) {endpack();}
  401.     elsif ($line =~ s/@@\@OSR5DIST\((.*)\)//) {osr5dist($1);}
  402.     elsif ($line =~ s/@@\@UW2DIST\((.*)\)//) {uw2dist($1);}
  403.     elsif ($line =~ s/@@\@SOURCE\((.*)\)//) {source($1);}
  404.     elsif ($line =~ s/@@\@HOMEPAGE\((.*)\)//) {homepage($1);}
  405.     elsif ($line =~ s/@@\@PACKLIST\((.*)\)//) {packlist($1);}
  406.     else {print OUTPUT "$line\n";}
  407. }
  408.